
package iterator;


// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.E61D5035-8F3A-4F44-00F9-56E962D28EBA]
// </editor-fold> 
public class CompteCorrent2 {

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.BA8818E3-D61C-9F75-5B65-4E39DE187C17]
    // </editor-fold> 
    private String[] titulars;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.3A0B3099-A383-58F5-B36F-A33402154511]
    // </editor-fold> 
    private int index;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.F5D1744F-D457-19CD-6EB2-CD0553824E11]
    // </editor-fold> 
    public CompteCorrent2 () {
        titulars = new String[5];
        index = 0;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.7528068C-8FBF-D1C0-DE19-2DB6CE388E6F]
    // </editor-fold> 
    public int getIndex () {
        return index;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.E699018D-A5FF-CD2E-5438-FE6825580E14]
    // </editor-fold> 
    public void setIndex (int val) {
        this.index = val;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.46321EDB-0A04-A00F-5AAB-9C412FA933B6]
    // </editor-fold> 
    public String[] getTitulars () {
        return titulars;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.F220E181-DA64-4C93-9F87-25292C03E3B1]
    // </editor-fold> 
    public void setTitulars (String[] val) {
        this.titulars = val;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.2B78665A-EC94-04A0-7312-96A7FED23B8B]
    // </editor-fold> 
    public void add (String titular) {
     if (index < titulars.length) {
            titulars[index++] = titular;
        }
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.50E57926-B257-6BF3-CAAD-76405DD72502]
    // </editor-fold> 
    public Iterator iterator () {
        //retorna un objecte que crea al vuelo y que implementa iterator
        return new Iterator(){
            int it=0;

            public boolean hasNext() {
                return it<index;
            }

            public Object next() {
                return titulars[it++];

            }
        };
    }

}

